import time

from selenium import webdriver
from selenium.webdriver.chrome.options import Options


def main():

    driver = Options()
    driver.add_argument('--headless')
    # driver = webdriver.Chrome(chrome_options=driver)
    driver = webdriver.Chrome()
    depCity = input('出发地：')
    arrCity = input('目的地：')
    goDate = input('出发时间(2020-12-13)：')
    # 搜索页面
    print('————开始搜索————')
    driver.get('https://flight.qunar.com/')
    driver.find_element_by_name('fromCity').clear()
    driver.find_element_by_name('fromCity').send_keys(depCity)

    driver.find_element_by_name('toCity').clear()
    driver.find_element_by_name('toCity').send_keys(arrCity)

    driver.find_element_by_name('fromDate').clear()
    driver.find_element_by_name('fromDate').send_keys(goDate)
    driver.find_element_by_class_name('btn_search').click()
    time.sleep(10)
    driver.quit()


# 输入内容
main()
